package com.sensePlusVR.realGame;

import java.util.ArrayList;
import java.util.List;
import android.annotation.SuppressLint;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

@SuppressLint("DefaultLocale")
public class SubAction {
	private int minorIndex;
	private List<String>streamFiles;
	private SimapleAudio audioIdleFiles;
	private SimapleAudio audioLowFiles;
	private SimapleAudio audioMidFiles;
	private SimapleAudio audioFastFiles;
	
	public SubAction(JsonObject json, String dir){
		minorIndex = json.get("minor").getAsInt();
		streamFiles = new ArrayList<String>();
		JsonArray videofile = json.get("videofile").getAsJsonArray();
		for (int i = 0; i < videofile.size(); i++){
			streamFiles.add(dir + videofile.get(i).getAsString());
		}
		if (json.get("audioidle") != null)
			audioIdleFiles = new SimapleAudio(json.get("audioidle").getAsJsonArray(), dir);
		if (json.get("audiolow") != null)
			audioLowFiles = new SimapleAudio(json.get("audiolow").getAsJsonArray(), dir);
		if (json.get("audiomid") != null)
			audioMidFiles = new SimapleAudio(json.get("audiomid").getAsJsonArray(), dir);
		if (json.get("audiohigh") != null)
			audioFastFiles = new SimapleAudio(json.get("audiohigh").getAsJsonArray(), dir);
	}
	
	public int minor(){
		return minorIndex;
	}
	
	public String getIdleAudio(){
		if (audioIdleFiles == null){
			return null;
		}
		return audioIdleFiles.getRandomAudio();
	}
	
	public String getLowAudio(){
		if (audioLowFiles == null){
			return null;
		}
		return audioLowFiles.getRandomAudio();
	}
	
	public String getMidAudio(){
		if (audioMidFiles == null){
			return null;
		}
		return audioMidFiles.getRandomAudio();
	}
	
	public String getFastAudio(){
		if (audioFastFiles == null){
			return null;
		}
		return audioFastFiles.getRandomAudio();
	}
	
	public String toString(){
		return String.format("%d,%s,%s,%s", minorIndex, streamFiles.get(0), 
				streamFiles.get(1),streamFiles.get(2));
	}
}
